package com.sx.zongzhi.presenter;

import com.sx.zongzhi.MyApplication;
import com.sx.zongzhi.bean.ServiceObjectBean;
import com.sx.zongzhi.modle.ApiManager;
import com.sx.zongzhi.net.BaseCallBack;
import com.sx.zongzhi.net.BaseResult;
import com.sx.zongzhi.view.IServiceObjectView;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by XZY on 2017/11/30.
 *获取服务对象
 */
public class ServiceObjectPest {

    private IServiceObjectView objectView;

    public ServiceObjectPest(IServiceObjectView objectView) {
        this.objectView=objectView;
    }

    /**
     *
     * @param objectBigType 对象类型key
     * @param objectType  对象子类型key
     * @param name 对象名称
     */
    public void getServiceObjectList(String objectBigType,String objectType,String name){
        Map<String,Object> map=new HashMap<>();
        map.put("sid", MyApplication.sid);
        map.put("serviceObjectVo.objectBigType", objectBigType);
        map.put("serviceObjectVo.objectType", objectType);
        map.put("serviceObjectVo.name", name);
        new ApiManager().getServiceObject(map, new BaseCallBack<BaseResult<ServiceObjectBean>>() {
            @Override
            public void onSuccess(BaseResult<ServiceObjectBean> response) {
                objectView.getServiceObjectList(response.getData());
            }
            @Override
            public void onFailures(String message) {
                objectView.showError(message);
            }
        });
    }

}
